package pers.cz.business;

import pers.cz.mapper.DatabaseDtlMapper;
import pers.cz.model.DatabaseDtl;
import pers.cz.mybatisPlugin.PageRowBounds;
import pers.cz.pub.AbstractBusiness;

import java.util.List;

/**
 * @program: PostGirl-panent
 * @description: DataSyncBusiness
 * @author: Cheng Zhi
 * @create: 2021-05-26 16:14
 **/
public class DataSyncBusiness extends AbstractBusiness {

    /**
     * 添加数据库连接信息
     * @param databaseDtl
     * @return
     */
    public int addDatabaseDtl(DatabaseDtl databaseDtl) {

        int count = this.getMapper(DatabaseDtlMapper.class).insert(databaseDtl);
        return count;
    }

    /**
     * 查询所有的数据库连接名
     * @return
     */
    public List<DatabaseDtl> queryALLDataBaseDtl() {

       return this.getMapper(DatabaseDtlMapper.class).selectAllDatabaseDtl();
    }

    /**
     * 分页查询所有数据库连接参数
     * @param pageStart
     * @param pageLimit
     * @return
     */
    public List<DatabaseDtl> queryAllDataBaseDtlByPage(Integer pageStart, Integer pageLimit) {

        PageRowBounds pageRowBounds = new PageRowBounds(pageStart, pageLimit);

        return this.getMapper(DatabaseDtlMapper.class).selectAllDatabaseDtlByPage(pageRowBounds);
    }

    /**
     * 获取总数
     * @return
     */
    public Integer quertDataBaseDtlTotalNum() {

        return this.getMapper(DatabaseDtlMapper.class).selectDatabaseDtlTotalNum();
    }

    /**
     * 修改
     * @param databaseDtl
     * @return
     */
    public Integer updateDataBaseDtl(DatabaseDtl databaseDtl) {

        return this.getMapper(DatabaseDtlMapper.class).updateByPrimaryKeySelective(databaseDtl);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    public Integer deleteDataBaseDtl(Integer id) {

        return this.getMapper(DatabaseDtlMapper.class).deleteByPrimaryKey(id);
    }


}
